package stack;

import java.util.Arrays;

public class Stack {
	
	public int size() {
		int num=0;
		if(arr.length==0)
		return 0;
		for (int i = 0; i < arr.length; i++) {
			if(arr[i]!=null){
				num++;
			}
		}
		return num;

	}
	
	@Override
	public char push(char item) {
		if(item==null) return null;
		if(top==arr.length) return null;
		arr[top++]=item;
		return item;
	}
	

	public String pop() {
		if(this.empty()){
		return null;
		}
		top--;
		Integer x=this.top;
		this.top=-1;
		return x;
		
	}
	
	@Override
	public String peek() {
		if(arr.length==0)
		return null;
		return this.top;
	}
	
	@Override
	public boolean empty() {
		if(arr.length==0){
			return true;
		}
		return false;
	}
	@Override
	public String toString() {
		return Arrays.toString(arr);
	}

}
